<template>
	<view class="my">
		<view class="my_item" v-for="item in cartlist" :key="item.id" @click="makecart" :data-park="item">
			<text>{{item.plateNo}}</text>
			<text class="type">{{item.type}}</text>
		</view>
		
	</view>
</template>

<script setup>
import {getcart} from '@/api/parkApi.js'	
import { onMounted, ref } from 'vue';
import {mycart} from '@/mock/park.js'

const cartlist = ref() //车辆列表

//点击修改我的车辆
const makecart=(e)=>{
	let parkde=e.currentTarget.dataset.park
	uni.navigateTo({
		url:`/pages/park/cart/makecart/makecart?park=${JSON.stringify(parkde)}`
	})
}

//查询我的车辆
const getcartdata= async()=>{
	let res = await getcart({
		header:{
			'Authorization':uni.getStorageSync('token')
		}
	})

	if(res.code==200){
	  cartlist.value=res.rows	
	}else{
		//静态数据
		 cartlist.value=mycart()	
	}
	console.log(cartlist.value);
}

onMounted(()=>{
	getcartdata()
})
</script>
<style lang="scss">
.my{
	padding:6px 10px;
	
	.my_item{
		margin: 10px 0px;
		padding: 16px 6px;
		font-size: 18px;
		font-weight: 700;
		display: flex;
		justify-content: space-between;
		background-color: #ddeeef;
		border-radius: 10px;
		
	
	}
}
</style>
